/* menu.cpp
  A simple menu, with some menu item handlers.
*/
#include <yawl.h>

class ThisWindow: public TFrameWindow {
public:
   ThisWindow();

// all menu handlers are of this prototype;
// the single argument (usually ignored) is 
// the menu id.
    void do_this(int);
    void do_that(int);

    void do_exit(int)
    { close(); }
};

ThisWindow *w;

ThisWindow::ThisWindow()
 : TFrameWindow("showing a menu",true)
{
  
// please note the cast (EH); it's necessary
// because C++ is too strict in this case.  However,
// it does mean that you can accidently force a
// handler of the wrong type; you have been warned.
  Menu(this)
  << (Popup("First")
       << Item("&do this\tctrl-A",(EH)do_this)
       << Item("do &that\tctrl-B",(EH)do_that)
    )
  << (Popup("Exit")
    << Item("&Close\tctrl-Q",(EH)do_exit)
   )
  ;
}

// it's generally a good idea to define non-trivial handlers
// outside the class body;  in particular, this means you
// can incrementally recompile them! (ctrl-I)
void ThisWindow::do_this(int)
{
 message("do this!");
}

void ThisWindow::do_that(int)
{
  set_status_text(0,"do that!");
}

int main(int argc, char**argv)
{
  w = new ThisWindow();
  w->show();
  w->run();
  return 0;
}
